package com.ruoyi.management.branch.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.management.branch.vo.BranchsVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.management.branch.mapper.TBranchMapper;
import com.ruoyi.management.branch.domain.TBranch;
import com.ruoyi.management.branch.service.ITBranchService;
import org.springframework.transaction.annotation.Transactional;

/**
 * 分行Service业务层处理
 * 
 * @author ruoyi
 * @date 2021-12-07
 */
@Service
public class TBranchServiceImpl implements ITBranchService 
{
    @Autowired
    private TBranchMapper tBranchMapper;

    /**
     * 查询分行
     * 
     * @param id 分行主键
     * @return 分行
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public TBranch selectTBranchById(Long id)
    {
        return tBranchMapper.selectTBranchById(id);
    }

    /**
     * 查询分行列表
     * 
     * @param tBranch 分行
     * @return 分行
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<TBranch> selectTBranchList(TBranch tBranch)
    {
        return tBranchMapper.selectTBranchList(tBranch);
    }

    /**
     * 新增分行
     * 
     * @param tBranch 分行
     * @return 结果
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public int insertTBranch(TBranch tBranch)
    {
        tBranch.setCreateTime(DateUtils.getNowDate());
        return tBranchMapper.insertTBranch(tBranch);
    }

    /**
     * 修改分行
     * 
     * @param tBranch 分行
     * @return 结果
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public int updateTBranch(TBranch tBranch)
    {
        tBranch.setUpdateTime(DateUtils.getNowDate());
        return tBranchMapper.updateTBranch(tBranch);
    }

    /**
     * 批量删除分行
     * 
     * @param ids 需要删除的分行主键
     * @return 结果
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public int deleteTBranchByIds(Long[] ids)
    {
        return tBranchMapper.deleteTBranchByIds(ids);
    }

    /**
     * 删除分行信息
     * 
     * @param id 分行主键
     * @return 结果
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public int deleteTBranchById(Long id)
    {
        return tBranchMapper.deleteTBranchById(id);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<BranchsVo> branchs() {
        return tBranchMapper.branchs();
    }
}
